1.安装GIT

  1. 下载https://desktop.github.com
  2. 直接安装
  3. 验证成功
    1
    git --version
验证git安装成功
验证git安装成功
  1. 配置

    1
    2
    git config --global user.name "your name"
    git config --global user.email "your_email@example.com"
  2. SSH Key

    1
    ssh-keygen -t rsa -C "your_email@example.com"
SSH Key生成
SSH

2.github配置

  1. 添加SSH Key
    把上一步生成的公钥拷贝,添加到github的keys。
    在GitHub上面添加本地SSH密钥信息,在右上角选择Settings进入设置界面:
    github 添加sshkey
    github
  2. git本地
    1
    2
    3
    4
    5
    eval `ssh-agent -s`
    ssh-add hexo_rsa //上面创建的密钥文件名
    ```
    3. **关联github验证**
    登陆一下GitHub,看是否登陆成功

ssh -T git@github.com

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
![验证关联github](http://p05jnww1u.bkt.gdipper.com/17-12-19/86864470.jpg "验证关联github")

#### 3.创建并验证github pages
1. **创建项目**
仓库名必须遵守相应格式:your_username.github.io,这样子在访问主页的时候直接用your_username.github.io就能访问。
![创建github项目](http://p05jnww1u.bkt.gdipper.com/17-12-19/77846075.jpg "创建github项目")
2. **git clone项目到本地**
3. **项目中添加一个文件:index.html**
``` vbscript-html
<!DOCTYPE html>
<html>
<body>
<h1>Hello World</h1>
<p>I'm hosted with GitHub Pages.</p>
</body>
</html>
```
4. **上传**
![上传github](http://p05jnww1u.bkt.gdipper.com/17-12-19/68948844.jpg "上传github")
![](http://p05jnww1u.bkt.gdipper.com/17-12-19/23380422.jpg)
5. **找到URL**
github上,setting中
![](http://p05jnww1u.bkt.gdipper.com/17-12-19/99367026.jpg)
![](http://p05jnww1u.bkt.gdipper.com/17-12-19/75068787.jpg)
5. **验证**
复制该URL到浏览器
![](http://p05jnww1u.bkt.gdipper.com/17-12-19/15034423.jpg)

#### 4.hexo配置git
1. **将hexo的文件夹拷贝到上边的本地项目中**
2. **修改hexo/_config.yml**

deploy:
type: git
repo:
github: https://github.com/lishanying/lishanying.github.io.git
branch: master

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
注意:中间有空格
3. **绑定git**
```
cnpm install hexo-deployer-git --save
```
![hexo绑定git](http://p05jnww1u.bkt.gdipper.com/17-12-19/51470286.jpg "hexo绑定git")
注意:如果此处不绑定,后续操作会出现如下异常:
![未绑定git的异常](http://p05jnww1u.bkt.gdipper.com/17-12-19/45801615.jpg "未绑定git的异常")

#### 4.部署到github
1. **部署**
一般我们上传到GitHub的时候我们用下边命令来执行,生成静态文件并且部署到服务器。
```
hexo clean
hexo g
hexo d
```
中途会提示输入github的账号和密码。
2. **验证**
![验证github托管](http://p05jnww1u.bkt.gdipper.com/17-12-19/32454140.jpg "验证github托管")

#### 5.部署到OSChina
1. **上传sshkey**
2. **验证关联**
3. **配置站点脚本**

deploy:
type: git
repo:
github: https://github.com/lishanying/lishanying.github.io.git
oschina: https://gitee.com/freeCunChangDaRen/freeCunChangDaRen.git
branch: master

4. **部署**

hexo clean
hexo g
hexo d
```
中途会提示输入github和OSChina的账号和密码。

  1. 验证
    验证OSChina托管
    验证OSChina托管